package com.gitee.wsl

/*import com.squareup.moshi.JsonClass
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory*/


/*
class DictionaryImpUnitTest {

    val jsonSerializer= Moshi.Builder().addLast(KotlinJsonAdapterFactory()).build()

    val storeServer= MemoryStoreServer.get()

    @Test
    fun dictionaryCreateTest(){

        println(jsonSerializer.adapter(DictionaryImp::class.java).toJson(buildDictionary_S_I()))

        println(jsonSerializer.adapter(DictionaryImp::class.java).toJson(buildDictionary_S_S()))

        println(jsonSerializer.adapter(DictionaryImp::class.java).toJson(buildDictionary_S_C()))
    }

    @Test
    fun testDictSave(){
        initDict()
        (1..8).forEach{
            val sample=DictSample(storeServer,it)
            println("               key:$it->value:${sample.dictionaryVer}\t sample value:${sample.dictionaryItemVer}")
            sample.key++
            println("after change   key:$it->value:${sample.dictionaryVer}\t sample value:${sample.dictionaryItemVer}")
            println()
        }
    }


    private fun initDict(){
        initItemDict()
        if(DictionaryExt.isExits(storeServer, DictSample.SAMPLE_DICT_NAME))
            return
        val sampleDict= DictionaryExt.getDictionary<Int,String>(storeServer, DictSample.SAMPLE_DICT_NAME)
        (1..20).forEach{
            sampleDict.put(it," value $it")
        }

        DictionaryExt.flushDictionary<Int,String>(storeServer,sampleDict)

    }

    private fun initItemDict(){
        if(DictionaryExt.isExits(storeServer, DictSample.SAMPLE_DICT_NAME+1))
            return
        val sampleDict=
            DictionaryExt.getDictionary<String,SampleDictItem>(storeServer, DictSample.SAMPLE_DICT_NAME+1)
        (1..20).forEach{
            sampleDict.put(it.toString(), SampleDictItem(it.toString(),"Sample value $it"))
        }
        DictionaryExt.flushDictionary(storeServer,sampleDict)

    }

    private fun buildDictionary_S_I(): DictionaryImp<String, Int> {
        val dict= DictionaryImp<String,Int>("dict_sample")
        (1..7).forEach {
            dict.put("key$it",it)
        }
        return dict
    }

    private fun buildDictionary_S_S(): DictionaryImp<String, String> {
        val dict= DictionaryImp<String,String>("dict_sample")
        (1..7).forEach {
            dict.put("key$it",it.toString())
        }
        return dict
    }

    private fun buildDictionary_S_C(): DictionaryImp<String, SampleDictItem> {
        val dict= DictionaryImp<String,SampleDictItem>("dict_sample")
        (1..7).forEach {
            dict.put("key$it",SampleDictItem(it.toString(),"value_$it"))
        }
        return dict
    }

}


@JsonClass(generateAdapter = true)
data class SampleDictItem(val name:String,val title:String)


class DictSample(storeServer: StoreServer,var key:Int){

    val dictionaryVer by DictionaryVer<Int,String>(storeServer,SAMPLE_DICT_NAME){
         key
    }

    val dictionaryItemVer by DictionaryVer<String,SampleDictItem>(storeServer,SAMPLE_DICT_NAME+1){
        key.toString()
    }

    companion object{
       const val SAMPLE_DICT_NAME="sampleDict"
    }

}*/
